import serial.tools.list_ports
import hid,wmi

def get_com_port():
    """
    获取windwos所有USB(COM)设备列表
    :return:USB(COM)设备列表
    """
    ports = list(serial.tools.list_ports.comports())
    return [f"{dev.device} - {dev.description}" for dev in ports]

def get_hid_port():
    """
    获取windwos所有USB(HID)设备列表
    :return:USB(HID)设备列表
    """
    devices = hid.enumerate(vendor_id=0, product_id=0)
    return [f"{dev['vendor_id']} - {dev['product_id']} - {dev['manufacturer_string']}" for dev in devices]

def get_net_adapter():
    """
    获取windwos所有网卡设备列表
    :return:网卡设备列表
    """
    c = wmi.WMI()
    return [f"{dev.IPAddress[0]} - {dev.Description}" for dev in c.Win32_NetworkAdapterConfiguration(IPEnabled=True)]

if __name__ == '__main__':
    ad_list = get_net_adapter()
    for i in ad_list:
        print(i)
